package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.CollectDianpuBean;
import com.lwj.liwanjia.impl.CollectDianpuView;
import com.lwj.liwanjia.model.CollectDianpuModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/11.
 */

public class CollectDianpuPresenter {
    private CollectDianpuView collectDianpuView;
    private CollectDianpuModel collectDianpuModel;

    public CollectDianpuPresenter(CollectDianpuView collectDianpuView) {
        this.collectDianpuView = collectDianpuView;
        collectDianpuModel = new CollectDianpuModel();
    }

    public void collectDianpu(String token, int shopInfoId) {
        if (collectDianpuView != null) {
            collectDianpuModel.collectDianpu(token, shopInfoId, new Subscriber<CollectDianpuBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    collectDianpuView.showError((Exception) e);
                }

                @Override
                public void onNext(CollectDianpuBean collectDianpuBean) {
                    collectDianpuView.collectDianpu(collectDianpuBean);
                }
            });
        }
    }
}
